package com.wjx.reservation_service.service.impl;

import com.wjx.reservation_service.dao.UserDao;
import com.wjx.reservation_service.model.User;
import com.wjx.reservation_service.service.IUserService;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IUserServiceImpl implements IUserService {
    @Autowired
    private UserDao userDao;
    //登录处理
    public User selectUserByUsername(String username){
        return userDao.selectUserByUsername(username);
    }
    //注册处理
    public int register(String username,String password,String authority){
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        user.setAuthority(authority);
        return userDao.addUser(user);
    }
    public User queryUserById(int id){
        return userDao.queryUserById(id);
    }
    //查询所有用户
    public List<User> queryAllUser(){
        return userDao.queryAllUser();
    }
    //根据用户名模糊查询
    public List<User> queryLikeUsername(String keyword){
        return userDao.queryLikeUsername(keyword);
    }
    //根据id更新用户
    public int updateUserById(User user){
        return userDao.updateUserById(user);
    }
    //根据id删除用户
    public int deleteUserById(int id){
        return userDao.deleteUserById(id);
    }
}
